"""
内容:将分享封装成一个类

"""
#引入
from ECShop_no9.common.base import create_browser,Base,create_browser_op
import time


class PageTag01(Base):

    #属性
    url = 'http://localhost:8080/ecshop/user.php'
    first = ('link text', '首页')
    sport_camera = ('xpath', ("//img[@src='images/201605/thumb_img/64_thumb_G_1462952811633.jpg']"))
    tag_element=('id','tag')
    content_click=('class name','bnt_blue')
    user = ('link text', '用户中心')
    click_tag=('link text','我的标签')

    get_text=('link text','这是运动相机的标签')
    #方法
    #打开网页
    def page_tag_web(self):
        self.base_open_web(self.url)
    #点击首页
    def page_tag_first(self):
        self.base_click(self.first)
    #点击运动相机
    def page_tag_sport_camera(self):
        self.base_click(self.sport_camera)
    #点击标签输入框
    def page_tag_content(self,content):
        self.base_input_content(self.tag_element,content)
    #点击添加按钮
    def page_tag_add_tag(self):
        self.base_click(self.content_click)

    # 进入用户中心
    def page_tag_user(self):
        self.base_click(self.user)

    #点击标签
    def page_tag_click_tag(self):
        self.base_click(self.click_tag)
    #获取新的标签
    def page_tag_get_tag(self):
        result=self.base_get_text(self.get_text)
        return result
    #关闭网页
    def page_tag_quit(self):
        self.base_quit()

if __name__ == '__main__':
    p1=PageTag01(create_browser_op(r'C:\Users\lenovo\AppData\Local\Google\Chrome\User Data'))
    p1.page_tag_web()
    p1.page_tag_first()
    p1.page_tag_sport_camera()
    p1.page_tag_content('这是运动相机的标签')
    p1.page_tag_add_tag()
    p1.page_tag_user()
    time.sleep(4)
    p1.page_tag_click_tag()
    time.sleep(4)
    print(p1.page_tag_get_tag())

